package com.drojian.operator;

import org.junit.Test;

import io.reactivex.Observable;
import io.reactivex.ObservableEmitter;
import io.reactivex.ObservableOnSubscribe;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

public class CreateOperator {
    @Test
    public void Test1(){
        System.out.println("aaa");
        CreateOperator operator = new CreateOperator();
        operator.Test2();
        System.out.println("bbb");
    }

   private void Test2(){
       Disposable subscribe = Observable.create(new ObservableOnSubscribe<Object>() {
           @Override
           public void subscribe(ObservableEmitter<Object> emitter) throws Exception {
               emitter.onNext("111");
               emitter.onNext("222");
               emitter.onNext("333");
           }
       }).subscribe(new Consumer<Object>() {
           @Override
           public void accept(Object o) throws Exception {
               System.out.println(o);
           }
       }, new Consumer<Throwable>() {
           @Override
           public void accept(Throwable throwable) throws Exception {
               System.out.println(throwable);
           }
       });
   }
}
